Table of Contents
The best way to build UltraDefrag is to use the Windows Server 2003 Driver Development Kit (DDK). You can simply download it from one of the locations that can be found using any web search system (e.g. Google).
The only disadvantage of this method is that the Windows DDK is a really big package (about 230 Mb). However, if you have an internet connection with a good download rate, its should not be a large problem.
Other interesting way to produce UltraDefrag package is to do so using MinGW. GNU C Compiler (GCC) has one important advantage over the Microsoft C compiler, it produces many useful warnings for code that is not completely within the C standard. I have removed hundreds of small bugs from UltraDefrag thanks to the warnings produced by GCC. The biggest disadvantage of gcc is that it produces larger executables than the microsoft compiler, e.g. a driver produced by DDK may have 22.0 Kb size, but the same driver produced by GCC is only about 32.0 kb.
You can either download MinGW from mingw.org or download MinGW Developer Studio from parinyasoft.com (about 25 Mb).
Note that the MinGW build system can only build i386 binaries.
VERY IMPORTANT NOTE: If you build the dynamic libraries from the MinGW Developer Studio, the resulting *.a files are invalid. This is because I don't know how to specify linker options in Developer Studio's project file. Use makefiles instead:
mingw32-make Makefile.mingw
This is another method for building UltraDefrag. It does not require the DDK. You can use Microsoft C compiler included in MS Visual Studio version 6.0 or later.
To use this method you will need to obtain a copy of ReactOS source code from ReactOS website for special header files used to build the driver.
You will also need to download the following files: ntdll.lib and ntoskrnl.lib + hal.lib (included in KmdKit package). Put these files to lib subdirectory of your Visual Studio installation.
VERY IMPORTANT NOTE: The winnt.h file in visual studio 6.0 contains an incorrect definition of the NtCurrentTeb function. Therefore replace the following lines:
#if defined(_M_ALPHA)
#define NtCurrentTeb() ((struct _TEB *)_rdteb())
#else
struct _TEB *
NtCurrentTeb(void);
#endif
with:
#if defined(_M_ALPHA)
#define NtCurrentTeb() ((struct _TEB *)_rdteb())
#else
struct _TEB *
__stdcall NtCurrentTeb(void);
#endif
Finally, edit ultradfg.dsp file (driver project file), and ensure that the reactos header paths are properly set.
Note that currently only i386 binaries can be produced using this way.
There are a few other tools that you should have installed on your PC to perform a full-featured build:
!packhdr temp.dat '"C:\WINDOWS\upx" -9 -q temp.dat'
robodoc
To produce more detailed developer manual, type:
robodoc --internal
Because the actual work done by UltraDefrag is done by kernel mode driver, you can download the tools described below to troubleshoot bugs. Even if you are not programmer, these tools may be very useful for you:
DebugView. Its window will show you some interesting information given by driver engine: number of clusters on your volumes, mft position and much more.
Some other useful tools available from sysinternals are:
Many of described tools have small size, and you don't need high-speed internet connection to download their latest versions. Simply do it.
If you will place tools executables in one of the directories, specified in your PATH environment variable, the command execution will be very easy process, because you can type commands without paths in the command prompt.
perl configure.pl
This tool has a graphical interface. Enter the paths to prerequisite libraries and other options. If you prefer to use MinGW, click the button
to replace some libraries included in MinGW (libntdll.a and libntoskrnl.a) with more adequate versions. Old libraries will be saved in files with additional suffix '.orig'.Here is an example:
build - perform the build using default options
build --install - run installer silently after the build
build [--use-winddk or --use-mingw or --use-msvc] [--install]
- specify your favorite compiler
build --clean - perform full cleanup instead of the build
build --help - show help message